<template>
  <div>
    <el-dialog
      :title="typeof userdata.id == 'number' ? '修改' : '新增'"
      :visible.sync="dialogVisible"
      :modal="false"
      width="40%"
      :before-close="handleClose"
    >
      <Form :userdata="userdata" ref="Form" />
      <span slot="footer" class="dialog-footer">
        <el-button @click="close">取 消</el-button>
        <el-button type="primary" @click="comfirm">确 定</el-button>
      </span>
    </el-dialog>
  </div>
</template>

<script>
import Form from "./form.vue";
export default {
  components: {
    Form,
  },
  props: {
    userdata: {
      type: Object,
      default: () => {
        return {};
      },
    },
  },
  data() {
    return {
      dialogVisible: false,
    };
  },
  methods: {
    comfirm() {
      this.$emit("change", this.$refs.Form.getForm());
      this.close();
    },
    open() {
      this.dialogVisible = true;
    },
    close() {
      this.dialogVisible = false;
    },
    handleClose(done) {
      this.$confirm("确认关闭？").then(() => {
        this.close();
      });
    },
  },
};
</script>

<style>
</style>